{include file="public/head"}
<style>
    .aui-address-cell-ft .button{
        display: inline-block;
        width: 23px;
        height: 22px;
        line-height: 22px;
        text-align: center;
        background: #fff;
        font-size: 16px;
        color: #666;
    }

    .aui-address-cell-ft .minus{
        border-right: 1px solid #e0e0e0;
    }

    .aui-address-cell-ft .plus{
        border-left: 1px solid #e0e0e0;
    }

    .aui-address-cell-ft .num{
        width: 32px;
        text-align: center;
        border: none;
        display: inline-block;
        height: 100%;
        box-sizing: border-box;
        vertical-align: center;
        margin: 0 0px;
    }

</style>
<body>
<header class="aui-header-default aui-header-fixed aui-header-bg">
    <a href="javascript:history.back(-1)" class="aui-header-item">
        <i class="aui-icon aui-icon-back-white"></i>
    </a>
    <div class="aui-header-center aui-header-center-clear">
        <div class="aui-header-center-logo">
            <div class="aui-car-white-Typeface" style="color:black;font-weight: bold;">填写订单</div>
        </div>
    </div>
    <a href="#" class="aui-header-item-icon"   style="min-width:0">
<!--        <i class="aui-icon aui-icon-member"></i>-->
    </a>
</header>
<section class="aui-address-content">
    <div class="aui-address-box">
        <div class="aui-address-box-list">
            <a href="{:url('User/AddressList',['goods_id'=>$GoodsInfo.id])}" class="aui-address-box-default">
                {if condition="$Address.name == null"}
                <ul>
                    <li>
                        <strong>暂无默认地址</strong>
                    </li>
                    <li>
                        点击前往添加
                    </li>
                </ul>
                {else/}
                <ul>
                    <li>
                        <strong>{$Address.name} {$Address.phone}</strong>
<!--                        <span class="aui-tag" id="aui-home">家里</span>-->
                        <span class="aui-tag aui-tag-default" id="aui-default">默认</span>
                    </li>
                    <li>
                        <i class="aui-icon aui-icon-address"></i>
                        {$Address.area}{$Address.address}
                    </li>
                </ul>
                {/if}
            </a>
        </div>
    </div>
    <div class="aui-dri"></div>
    <div class="aui-list-product-float-item">
        <a href="javascript:;" class="aui-list-product-fl-item">
            <div class="aui-list-product-fl-img">
                <img src="{$GoodsInfo.logo_url}" alt="">
            </div>
            <div class="aui-list-product-fl-text">
                <h3 class="aui-list-product-fl-title" style="font-size: 1rem;line-height: 1.5rem;margin-bottom: 0">{$GoodsInfo.name}</h3>
                <div class="aui-list-product-fl-mes">
                    <div>
                        <span class="aui-list-product-item-price" style="color: silver;font-size: .8rem">
                            {$GoodsInfo.introduction}
                        </span>
                    </div>
                </div>

                <div class="aui-list-product-fl-mes">
                    <div>
                        <span class="aui-list-product-item-price">
                            <!--<em>¥</em>-->
                            <!--<span class="price">{if condition="$UserInfo.level gt 1"}{$GoodsInfo.hyprice}{else/}{$GoodsInfo.price}{/if}</span>-->
                            {if condition="$GoodsInfo['goods_type'] eq 3"}
                            <i>￥</i>
                			<span class="price">
                			{if condition="$UserInfo.level eq 1"}{$GoodsInfo.price}{elseif condition="$UserInfo.level eq 2"}{$GoodsInfo.hyprice}{elseif condition="$UserInfo.level eq 3"}{$GoodsInfo.dlprice}{elseif condition="$UserInfo.level eq 4"}{$GoodsInfo.dpprice}{elseif condition="$UserInfo.level eq 5"}{$GoodsInfo.qxprice}{elseif condition="$UserInfo.level eq 6"}{$GoodsInfo.sjprice}{elseif condition="$UserInfo.level eq 7"}{$GoodsInfo.shprice}{elseif condition="$UserInfo.level eq 8"}{$GoodsInfo.hhrprice}{/if}
                			</span>
                			{elseif condition="$GoodsInfo['goods_type'] eq 5 && $pttype == 1"}
                			<i>￥</i><span class="price">{$GoodsInfo['quan']}</span>
                			{else/}
                			<i>￥</i><span class="price">{$GoodsInfo['price']}</span>
                			{/if}
                        </span>
<!--                        <span class="aui-list-product-item-del-price">-->
<!--								¥495.65-->
<!--							</span>-->
                    </div>
                    <div class="aui-btn-purchase">
                        <span>/{$GoodsInfo.unit}</span>
                    </div>
                </div>
                <div class="aui-list-product-fl-bag">

                    <span><img src="__STATIC__/User/img/icon/bag1.png" alt=""></span>
                    <span><img src="__STATIC__/User/img/icon/bag2.png" alt=""></span>
                </div>
            </div>
        </a>
    </div>
    <div class="aui-address-well">
        <div class="aui-dri"></div>
        {if condition="$GoodsInfo['goods_type'] neq 1"}
        <a href="#" class="aui-address-cell aui-fl-arrow-clear" >
            <div class="aui-address-cell-bd">数量</div>
            <div class="aui-address-cell-ft">
                <div style="border: silver 1px solid">
                    <span class="button minus">-</span>
                    <span class="num">1</span>
                    <span class="button plus">+</span>
                </div>
            </div>
        </a>
        {else/}
        <span class="num" style="display: none">1</span>
        {/if}
        <div class="aui-dri" style="height: 1px"></div>

        <a href="#" class="aui-address-cell aui-fl-arrow-clear">
            <div class="aui-address-cell-bd">配送</div>
            <div class="aui-address-cell-ft">快递</div>
        </a>
        <div class="aui-dri" style="height: 1px"></div>
        
        <a href="#" class="aui-address-cell aui-fl-arrow-clear">
            <div class="aui-address-cell-bd">邮费</div>
            <div class="aui-address-cell-ft">{$you}</div>
        </a>
        
        {if condition="$GoodsInfo.goods_type eq 1"}
        <a href="#" class="aui-address-cell aui-fl-arrow-clear">
            <div class="aui-address-cell-bd">积分</div>
            <div class="aui-address-cell-ft">{$UserInfo.balance_1}</div>
        </a>
        {else/}
        <a href="#" class="aui-address-cell aui-fl-arrow-clear">
            <div class="aui-address-cell-bd">余额</div>
            <div class="aui-address-cell-ft">{$UserInfo.balance_4}</div>
        </a>
        {/if}
        <div class="aui-dri" style="height: 1px"></div>

    </div>
    <div class="aui-payment-bar">
        <div class="shop-total">
            <span class="aui-red aui-size">实付款: ￥<em class="total_price">
                {if condition="$GoodsInfo['goods_type'] eq 3"}
                    {if condition="$UserInfo.level eq 1"}
                        {$GoodsInfo.price + $you}
                    {elseif condition="$UserInfo.level eq 2"}
                        {$GoodsInfo.hyprice + $you}
                    {elseif condition="$UserInfo.level eq 3"}
                        {$GoodsInfo.dlprice + $you}
                    {elseif condition="$UserInfo.level eq 4"}
                        {$GoodsInfo.dpprice + $you}
                    {elseif condition="$UserInfo.level eq 5"}
                        {$GoodsInfo.qxprice + $you}
                    {elseif condition="$UserInfo.level eq 6"}
                        {$GoodsInfo.sjprice + $you}
                    {elseif condition="$UserInfo.level eq 7"}
                        {$GoodsInfo.shprice + $you}
                {elseif condition="$UserInfo.level eq 8"}
                        {$GoodsInfo.hhrprice + $you}
                    {/if}
                {elseif condition="$GoodsInfo['goods_type'] eq 5 && $pttype == 1"}
                    {$GoodsInfo['quan'] + $you}
                {else/}
                    {$GoodsInfo['price'] + $you}
                {/if}</em></span>
        </div>
        
        <!--<a href="javascript:" class="settlement">立即参团</a>-->
        <a href="javascript:" class="settlement">立即购买</a>
    </div>
</section>

<script type="text/javascript" src="__STATIC__/User/js/jquery.min.js"></script>
<script type="text/javascript" src="__STATIC__/User/js/aui.js"></script>
<script>
var type;
if({:$pttype}){
    type = 1;
}else{
    type = 2;
}

    $(function () {
        //减少
        $('.minus').on('click',function () {
            let num = parseInt($(".num").html());
            if (num < 1) {
                num  = 1
            } else {
                num -= 1
            }
            if(num < 1){
                num = 1;
            }
            $(".num").html(num);
            setTotalPrice(num)
        })

        //增加
        $('.plus').on('click',function () {
            let num = parseInt($(".num").html());
            num += 1
            $(".num").html(num);
            setTotalPrice(num)
        })

        //总价
        function setTotalPrice (num) {
            let price = parseFloat($(".price").html());
            $(".total_price").html((price * num).toFixed(2));
        }

        //提交
        $('.settlement').on('click',function () {
            var goods_id = "{$GoodsInfo.id}";
            var num = parseInt($(".num").html());

            $.ajax({
                type:"POST",
                url:"{:url('Order/OrderFound')}",
                data:{
                    goods_id:goods_id,
                    num:num,
                    type:{$pttype},
                    pt_id:"{$pt_id}",
                    youfei:"{$you}",
                },
                dataType:"json",
                success:function(data){
                    if(data.status == 1){
                        alert(data.message);
                        var order_id = data.order_id;
                        window.location.href="/Order/OrderPay/order_id/"+order_id;
                    }else if(data.status == 2){
                        alert(data.message);
                        window.location.href="{:url('User/AddressList',['goods_id'=>$GoodsInfo.id])}";
                    }
                    else{
                        alert(data.message);
                    }
                }
            })
        })
    })
</script>

</body>
</html>